<?php
/**
 * Created by PhpStorm.
 * User: iraklis
 * Date: 12/4/13
 * Time: 7:14 PM
 */
session_start();
if (!isset($_SESSION["level"])) header("location:login.php");
?>

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <link rel="shortcut icon" href="./files/img/favicon.ico">
    <title>RemindMe - My Settings</title>
</head>

<link type="text/css" href="./files/jquery-ui/css/smoothness/jquery-ui-1.8.16.custom.css" rel="Stylesheet" />
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

<style type="text/css">
    @import "style2.css";
</style>

<script type="text/javascript" src="./scripts.js"></script>

<?php
include 'sql.php';
?>

<body>

<div id="access">
    <?php echo showRightPanel(); ?>
</div> <!--End of access-->

<!--
Start Header Area
-->
<div id="header">
     <?php showMenu(); ?>
</div><!-- End of HEADER -->

<!--
 Start Left Panel Area
 -->
<?php showLeftPanel($_SESSION['level'], $_SESSION['user']); ?>
<!--
End of Left_panel
-->

<!--
 Start Container Area
 -->

<div id="container">
    <div id="content"><!-- Content Area-->
        <div id="update_user" >
            <h2>Below you can change your personal settings</h2><br />
            <form name="update_form" action="sql.php" method="post" style="margin: 100 auto; height: 300px;">
                <input type="hidden" name="username" value= "<?php echo $_SESSION['user']; ?>" />
                <label>Current Password: </label>
                <p><input type="password" id="password" size="15" name="password" /></p>
                <label>New Password: </label>
                <p><input type="password" id="new_password" size="15" name="new_password" /></p>
                <label>Confirm Password: </label><br>
                <p><input type="password" id="password_confirm" size="15" name="password_confirm" /><img id="img"></p>
                <label>Email: </label>
                <p><input type="text" id="email" size="15" name="email" /></p>
                <label>Phone Number: </label>
                <p><input type="text" id="phone_number" size="15" name="phone_number" /></p>
                <p><input type="submit" name="update_user" value="Update!"/></p>
            </form>
        </div>
    </div><!--END of content-->
</div><!--END of container-->

<?php showFooter(); ?><!--END of footer-->
</body>

<script>
    $(document).ready(function(){
        $("#password_confirm").focusout(function(){
            var current_password = $("#password").val();
            var password = $("#new_password").val();
            var password_confirm = $("#password_confirm").val();
            if (password != "") {
                if (password == password_confirm) {
                    $("#img").attr('src', './files/img/tick.jpg');
                    $("#submit").removeAttr('disabled');

                }
                else {
                    $("#img").attr('src', './files/img/wrong.png');
                }
            }// end of outer if
            else {
                $("#img").attr('src', '');
            }
        });
        /*
         $("#submit").click(function() {
         var new_password = $("#new_password").val();
         var dataString = 'new_password=' + new_password;

         $.ajax({
         type: "POST",
         url: "sql.php",
         data: dataString,
         cache: false,
         success: function(html) {}
         });
         });*/
    });//end of ready
</script>

</html>